home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.3 / Printer / src / EpsonX / transfer.c < prev   
Encoding:
C/C++ Source or Header  |  1992-08-27  |  3.3 KB  |  131 lines

  1. /*
  2.     Transfer routine for EpsonX driver.
  3.     David Berezowski - October/87.
  4.  
  5.   Copyright (c) 1988 Commodore-Amiga, Inc.
  6.  
  7.   Executables based on this information may be used in software
  8.   for Commodore Amiga computers.  All other rights reserved.
  9.  
  10.   This information is provided "as is"; no warranties are made.
  11.   All use is at your own risk, and no liability or responsibility is assumed.
  12. */
  13.  
  14.  
  15. #include <exec/types.h>
  16. #include "../printer/printer.h"
  17. #include "../printer/prtbase.h"
  18. #include "../printer/prtgfx.h"
  19.  
  20. Transfer(PInfo, y, ptr, colors, BufOffset)
  21. struct PrtInfo *PInfo;
  22. UWORD y;        /* row # */
  23. UBYTE *ptr;        /* ptr to buffer */
  24. UWORD *colors;        /* indexes to color buffers */
  25. ULONG BufOffset;    /* used for interleaved printing */
  26. {
  27.     extern struct PrinterData *PD;
  28.     extern struct PrinterExtendedData *PED;
  29.  
  30.     static UWORD bit_table[8] = {128, 64, 32, 16, 8, 4, 2, 1};
  31.     union colorEntry *ColorInt;
  32.     UBYTE *bptr, *yptr, *mptr, *cptr, Black, Yellow, Magenta, Cyan;
  33.     UBYTE *dmatrix, dvalue, threshold;
  34.     UWORD x, width, sx, *sxptr, color, bit, x3;
  35.  
  36.     /* printer non-specific, MUST DO FOR EVERY PRINTER */
  37.     x = PInfo->pi_xpos;
  38.     ColorInt = PInfo->pi_ColorInt;
  39.     sxptr = PInfo->pi_ScaleX;
  40.     width = PInfo->pi_width;
  41.  
  42.     /* printer specific */
  43.     if (PED->ped_YDotsInch == 216) {
  44.         BufOffset *= y % 3;
  45.         y /= 3;
  46.     }
  47.     else if (PED->ped_YDotsInch == 144) {
  48.         BufOffset *= y & 1;
  49.         y /= 2;
  50.     }
  51.     else {
  52.         BufOffset = 0;
  53.     }
  54.     bit = bit_table[y & 7];
  55.     bptr = ptr + colors[0] + BufOffset;
  56.     yptr = ptr + colors[1] + BufOffset;
  57.     mptr = ptr + colors[2] + BufOffset;
  58.     cptr = ptr + colors[3] + BufOffset;
  59.  
  60.     /* pre-compute threshold; are we thresholding? */
  61.     if (threshold = PInfo->pi_threshold) { /* thresholding */
  62.         dvalue = threshold ^ 15;
  63.         bptr += x;
  64.         do { /* for all source pixels */
  65.             /* pre-compute intensity values for Black component */
  66.             Black = ColorInt->colorByte[PCMBLACK];
  67.             ColorInt++;
  68.  
  69.             sx = *sxptr++;
  70.  
  71.             do { /* use this pixel 'sx' times */
  72.                 if (Black > dvalue) {
  73.                     *bptr |= bit;
  74.                 }
  75.                 bptr++; /* done 1 more printer pixel */
  76.             } while (--sx);
  77.         } while (--width);
  78.     }
  79.     else { /* not thresholding, pre-compute ptr to dither matrix */
  80.         dmatrix = PInfo->pi_dmatrix + ((y & 3) << 2);
  81.         if (PD->pd_Preferences.PrintShade == SHADE_GREYSCALE) {
  82.             do { /* for all source pixels */
  83.                 /* pre-compute intensity values for Black */
  84.                 Black = ColorInt->colorByte[PCMBLACK];
  85.                 ColorInt++;
  86.  
  87.                 sx = *sxptr++;
  88.  
  89.                 do { /* use this pixel 'sx' times */
  90.                     if (Black > dmatrix[x & 3]) {
  91.                         *(bptr + x) |= bit;
  92.                     }
  93.                     x++; /* done 1 more printer pixel */
  94.                 } while (--sx);
  95.             } while (--width);
  96.         }
  97.         else { /* color */
  98.             do { /* for all source pixels */
  99.                 /* compute intensity values for each color */
  100.                 Black = ColorInt->colorByte[PCMBLACK];
  101.                 Yellow = ColorInt->colorByte[PCMYELLOW];
  102.                 Magenta = ColorInt->colorByte[PCMMAGENTA];
  103.                 Cyan = ColorInt->colorByte[PCMCYAN];
  104.                 ColorInt++;
  105.  
  106.                 sx = *sxptr++;
  107.  
  108.                 do { /* use this pixel 'sx' times */
  109.                     x3 = x >> 3;
  110.                     dvalue = dmatrix[x & 3];
  111.                     if (Black > dvalue) {
  112.                         *(bptr + x) |= bit;
  113.                     }
  114.                     else  { /* black not rendered */
  115.                         if (Yellow > dvalue) {
  116.                             *(yptr + x) |= bit;
  117.                         }
  118.                         if (Magenta > dvalue) {
  119.                             *(mptr + x) |= bit;
  120.                         }
  121.                         if (Cyan > dvalue) {
  122.                             *(cptr + x) |= bit;
  123.                         }
  124.                     }
  125.                     ++x; /* done 1 more printer pixel */
  126.                 } while (--sx);
  127.             } while (--width);
  128.         }
  129.     }
  130. }
  131.